package cn.t17.appsys.service.impl;

import cn.t17.appsys.dao.DevUserMapper;
import cn.t17.appsys.entity.DevUser;
import cn.t17.appsys.exception.BusinessException;
import cn.t17.appsys.service.DevUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.Objects;

/**
 * DevUserServiceImpl class
 *
 * @author Administrator
 * @date 2021/9/16
 */
@Service
public class DevUserServiceImpl implements DevUserService {
    @Autowired
    private DevUserMapper devUserMapper;
    @Override
    public DevUser login(String devCode, String devPassword)
            throws BusinessException{
        DevUser devUser = devUserMapper.getByDevCode(devCode);
        if(ObjectUtils.isEmpty(devUser)){
            throw new BusinessException("用户名不正确！");
        }
        if(!devUser.getDevPassword().equals(devPassword)) {
            throw new BusinessException("密码不正确！");
        }
        return devUser;
    }

}
